package cn.bone.spring.jms01;

import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

/**
 * Created by superbone on 2016/9/13.
 */
@Service
public class ProducerService {

    @Autowired
    private JmsTemplate template;

    public void sendMessage(){

        ActiveMQQueue queue = new ActiveMQQueue("demo.test01");

        template.send(queue,new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                return session.createTextMessage("第一个基于spring的jms");
            }
        });
    }
}
